home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 100 / CD-ROM 100.iso / aplic / oo1_1 / f_0020 / sbasic.jar / text / sbasic / common / 03090201.xml < prev    next >
Encoding:
Extensible Markup Language  |  2003-04-30  |  8.9 KB  |  67 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <html><head><title>Do...Loop Statement [Runtime]</title><meta name="filename" content="text/sbasic/common/03090201"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
  3.  
  4.         p.P1{
  5.                 }
  6.         span.T1{
  7.                 font-weight:bold;}
  8.         </style></head><body>
  9.   
  10.   
  11.   <help:paragraphinfo state="E" xmlns:help="http://openoffice.org/2000/help"/><help:to-be-embedded Eid="doloop" xmlns:help="http://openoffice.org/2000/help"><a name="doloop"/>
  12.   <p class="Head1"><help:paragraphinfo state="U" number="1"/><help:key-word value="Do; statement" tag="kw66463_1"/><help:key-word value="While; Do loop" tag="kw66463_3"/><help:key-word value="Until" tag="kw66463_2"/><help:link Id="66463">Do...Loop Statement [Runtime]</help:link></p>
  13.   <p class="Paragraph"><help:paragraphinfo state="U" number="2"/>Repeats the statements between the Do and the Loop statement while the condition is True or until the condition becomes True.</p>
  14.   <help:paragraphinfo state="E"/></help:to-be-embedded>
  15.   <p class="Head2"><help:paragraphinfo state="U" number="3" xmlns:help="http://openoffice.org/2000/help"/>Syntax</p>
  16.   <p class="Paragraph"><help:paragraphinfo state="U" number="4" xmlns:help="http://openoffice.org/2000/help"/>Do [{While | Until} condition = True]</p>
  17.   <p class="Paragraph"><help:paragraphinfo state="U" number="5" xmlns:help="http://openoffice.org/2000/help"/>statement block</p>
  18.   <p class="Paragraph"><help:paragraphinfo state="U" number="6" xmlns:help="http://openoffice.org/2000/help"/>[Exit Do]</p>
  19.   <p class="Paragraph"><help:paragraphinfo state="U" number="7" xmlns:help="http://openoffice.org/2000/help"/>statement block</p>
  20.   <p class="Paragraph"><help:paragraphinfo state="U" number="8" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="Loop" tag="kw66463_4" xmlns:help="http://openoffice.org/2000/help"/>Loop</p>
  21.   <p class="Paragraph"><help:paragraphinfo state="U" number="9" xmlns:help="http://openoffice.org/2000/help"/>or</p>
  22.   <p class="Paragraph"><help:paragraphinfo state="U" number="10" xmlns:help="http://openoffice.org/2000/help"/>Do</p>
  23.   <p class="Paragraph"><help:paragraphinfo state="U" number="11" xmlns:help="http://openoffice.org/2000/help"/>statement block</p>
  24.   <p class="Paragraph"><help:paragraphinfo state="U" number="12" xmlns:help="http://openoffice.org/2000/help"/>[Exit Do]</p>
  25.   <p class="Paragraph"><help:paragraphinfo state="U" number="13" xmlns:help="http://openoffice.org/2000/help"/>statement block</p>
  26.   <p class="Paragraph"><help:paragraphinfo state="U" number="14" xmlns:help="http://openoffice.org/2000/help"/>Loop [{While | Until} condition = True]</p>
  27.   <p class="Head2"><help:paragraphinfo state="U" number="15" xmlns:help="http://openoffice.org/2000/help"/>Parameters/Elements</p>
  28.   <p class="Paragraph"><help:paragraphinfo state="U" number="16" xmlns:help="http://openoffice.org/2000/help"/><span class="T1">Condition:</span> A comparison, numeric or string expression, that evaluates either True or False.</p>
  29.   <p class="Paragraph"><help:paragraphinfo state="U" number="17" xmlns:help="http://openoffice.org/2000/help"/><span class="T1">Statement block:</span> Statements that you want to repeat while or until the condition is True.</p>
  30.   <p class="Paragraph"><help:paragraphinfo state="U" number="18" xmlns:help="http://openoffice.org/2000/help"/>The <span class="T1">Do...Loop</span> statement executes a loop as long as, or until, a certain condition is True. The condition for exiting the loop must be entered following either the <span class="T1">Do</span> or the <span class="T1">Loop</span> statement. The following examples are valid combinations:</p>
  31.   <p class="Head2"><help:paragraphinfo state="U" number="19" xmlns:help="http://openoffice.org/2000/help"/>Syntax</p>
  32.   <p class="Paragraph"><help:paragraphinfo state="U" number="20" xmlns:help="http://openoffice.org/2000/help"/>Do While condition = True</p>
  33.   <p class="Paragraph"><help:paragraphinfo state="U" number="21" xmlns:help="http://openoffice.org/2000/help"/>...statement block</p>
  34.   <p class="Paragraph"><help:paragraphinfo state="U" number="22" xmlns:help="http://openoffice.org/2000/help"/>Loop</p>
  35.   <p class="Paragraph"><help:paragraphinfo state="U" number="24" xmlns:help="http://openoffice.org/2000/help"/>The statement block between the Do While and the Loop statements is repeated so long as the condition is true.</p>
  36.   <p class="Paragraph"><help:paragraphinfo state="U" number="25" xmlns:help="http://openoffice.org/2000/help"/>Do Until condition = True</p>
  37.   <p class="Paragraph"><help:paragraphinfo state="U" number="26" xmlns:help="http://openoffice.org/2000/help"/>...statement block</p>
  38.   <p class="Paragraph"><help:paragraphinfo state="U" number="27" xmlns:help="http://openoffice.org/2000/help"/>Loop</p>
  39.   <p class="Paragraph"><help:paragraphinfo state="U" number="29" xmlns:help="http://openoffice.org/2000/help"/>The statement block between the Do Until and the Loop statements is repeated if the condition so long as the condition is false.</p>
  40.   <p class="Paragraph"><help:paragraphinfo state="U" number="30" xmlns:help="http://openoffice.org/2000/help"/>Do</p>
  41.   <p class="Paragraph"><help:paragraphinfo state="U" number="31" xmlns:help="http://openoffice.org/2000/help"/>...statement block</p>
  42.   <p class="Paragraph"><help:paragraphinfo state="U" number="32" xmlns:help="http://openoffice.org/2000/help"/>Loop While condition = True</p>
  43.   <p class="Paragraph"><help:paragraphinfo state="U" number="34" xmlns:help="http://openoffice.org/2000/help"/>The statement block between the Do and the Loop statements repeats so long as the condition is true.</p>
  44.   <p class="Paragraph"><help:paragraphinfo state="U" number="35" xmlns:help="http://openoffice.org/2000/help"/>Do</p>
  45.   <p class="Paragraph"><help:paragraphinfo state="U" number="36" xmlns:help="http://openoffice.org/2000/help"/>...statement block</p>
  46.   <p class="Paragraph"><help:paragraphinfo state="U" number="37" xmlns:help="http://openoffice.org/2000/help"/>Loop Until condition = True</p>
  47.   <p class="Paragraph"><help:paragraphinfo state="U" number="39" xmlns:help="http://openoffice.org/2000/help"/>The statement block between the Do and the Loop statements repeats until the condition is true.</p>
  48.   <p class="Paragraph"><help:paragraphinfo state="U" number="41" xmlns:help="http://openoffice.org/2000/help"/>Use the <span class="T1">Exit Do</span> statement to unconditionally end the loop. You can add this statement anywhere in a <span class="T1">Do</span>...<span class="T1">Loop</span> statement. You can also define an exit condition using the <span class="T1">If...Then</span> structure as follows:</p>
  49.   <p class="Paragraph"><help:paragraphinfo state="U" number="42" xmlns:help="http://openoffice.org/2000/help"/>Do...</p>
  50.   <p class="Paragraph"><help:paragraphinfo state="U" number="43" xmlns:help="http://openoffice.org/2000/help"/>statements</p>
  51.   <p class="Paragraph"><help:paragraphinfo state="U" number="44" xmlns:help="http://openoffice.org/2000/help"/>If condition = True Then Exit Do</p>
  52.   <p class="Paragraph"><help:paragraphinfo state="U" number="45" xmlns:help="http://openoffice.org/2000/help"/>statements</p>
  53.   <p class="Paragraph"><help:paragraphinfo state="U" number="46" xmlns:help="http://openoffice.org/2000/help"/>Loop...</p>
  54.   <p class="Head2"><help:paragraphinfo state="U" number="47" xmlns:help="http://openoffice.org/2000/help"/>Example</p>
  55.   <p class="Paragraph"><help:paragraphinfo state="U" number="49" xmlns:help="http://openoffice.org/2000/help"/>Sub ExampleDoLoop</p>
  56.   <p class="Paragraph"><help:paragraphinfo state="U" number="50" xmlns:help="http://openoffice.org/2000/help"/>Dim sFile As String</p>
  57.   <p class="PropText"><help:paragraphinfo state="U" number="51" xmlns:help="http://openoffice.org/2000/help"/>Dim sPath As String</p>
  58.   <p class="PropText"><help:paragraphinfo state="U" number="52" xmlns:help="http://openoffice.org/2000/help"/>sPath = "c:\"</p>
  59.   <p class="PropText"><help:paragraphinfo state="U" number="53" xmlns:help="http://openoffice.org/2000/help"/>sFile = Dir$( sPath ,22)</p>
  60.   <p class="PropText"><help:paragraphinfo state="U" number="54" xmlns:help="http://openoffice.org/2000/help"/>If sFile <> "" Then</p>
  61.   <p class="PropText"><help:paragraphinfo state="U" number="55" xmlns:help="http://openoffice.org/2000/help"/>Do</p>
  62.   <p class="PropText"><help:paragraphinfo state="U" number="56" xmlns:help="http://openoffice.org/2000/help"/>MsgBox sFile</p>
  63.   <p class="PropText"><help:paragraphinfo state="U" number="57" xmlns:help="http://openoffice.org/2000/help"/>sFile = Dir$</p>
  64.   <p class="PropText"><help:paragraphinfo state="U" number="58" xmlns:help="http://openoffice.org/2000/help"/>Loop Until sFile = ""</p>
  65.   <p class="PropText"><help:paragraphinfo state="U" number="59" xmlns:help="http://openoffice.org/2000/help"/>End If</p>
  66.   <p class="PropText"><help:paragraphinfo state="U" number="60" xmlns:help="http://openoffice.org/2000/help"/>End Sub</p>
  67.  </body></html>